package com.gensdai.leliang;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.View;

import com.gensdai.leliang.utils.PreferencesUtils;
import com.gensdai.leliang.view.AppIntro3;
import com.gensdai.leliang.welcomeslide.FirstSlide;
import com.gensdai.leliang.welcomeslide.SecondSlide;
import com.gensdai.leliang.welcomeslide.ThirdSlide;

/**
 * Created by zsxx on 2017/9/11.
 */

public class WelcomeOne extends AppIntro3 {

    public static final String EXTRA_TYPE = "isOneInner";
    private int type = -1;   //type = 0从关于里面进入的

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        type = getIntent().getIntExtra(EXTRA_TYPE, -1);
        addSlide(new FirstSlide());
        addSlide(new SecondSlide());
        addSlide(new ThirdSlide());

        // Hide Skip/Done button.
        showSkipButton(true);
        setProgressButtonEnabled(true);
        // OPTIONAL METHODS
        // Override bar/separator color.
        setIndicatorColor(getResources().getColor(R.color.baseColor),getResources().getColor(R.color.icon_unselect_color));

        setVibrate(true);
        setVibrateIntensity(30);
    }


    @Override
    public void onSkipPressed(Fragment currentFragment) {
        super.onSkipPressed(currentFragment);
        // Do something when users tap on Skip button.
        startAct();
        this.finish();
    }

    @Override
    public void onDonePressed(Fragment currentFragment) {
        super.onDonePressed(currentFragment);
        startAct();
        this.finish();
        // Do something when users tap on Done button.
    }

    @Override
    public void onSlideChanged(@Nullable Fragment oldFragment, @Nullable Fragment newFragment) {
        super.onSlideChanged(oldFragment, newFragment);
        // Do something when the slide changes.
    }


    public void getStarted(View v) {
        startAct();
        this.finish();
    }

    private void startAct(){
        if(type != 0){
            startActivity(new Intent(this,MainBottomNavigation.class));
            PreferencesUtils.setBooleanPreference(this,
                    AppApplication.PREFERENCE_NAME,WelcomeActivity.isoneto, false);
        }
    }
}
